<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./AJAX.js"></script>
    <style>
      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
      }
      .container {
        width: 1200px;
        margin: 50px auto;
      }
      video {
        height: 400px;
      }
      .wrapper {
        height: 400px;
        display: flex;
        justify-content: center;
        align-items: center;
        background: #222;
      }
      h2{
        margin-bottom: 15px;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <h2></h2>
      <div class="wrapper">
        <video controls src=""></video>
      </div>
    </div>
    <script>
      //获取按钮元素
      let btn = document.querySelector("button");
      let video = document.querySelector("video");
      let h3 = document.querySelector("h2");

      (async () => {
        try {
          //发送请求
          let data = await sendAJAX("get", "http://api.xiaohigh.com/douyin/33");
          //设置 video 的 src 属性
          video.src = "http://cdn.xiaohigh.com" + data.video_local;
          //设置 h3 标签的文本
          h3.innerHTML = data.desc;
        } catch (e) {
          console.log(e);
        }
      })();
    </script>
  </body>
</html>
